﻿
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;

namespace 属性改变通知
{
    public class OrderSagaData : BaseSagaData
    {

        public OrderSagaData(string sagaId) : base(sagaId)
        {
            OrderCreated = true;

            var array = typeof(OrderSagaData).GetProperties();
            Console.WriteLine(1);
        }

        private bool orderCreated;
        private bool orderPaymented;
        private bool orderStockAdjusted;

        public bool OrderCreated
        {
            get => orderCreated;
            set
            {
                if (orderCreated != value)
                {
                    orderCreated = value;
                    NotifyPropertyChanged();
                }
            }
        }
        public bool OrderPaymented
        {
            get => orderPaymented;

            set
            {

                if (orderPaymented != value)
                {
                    orderPaymented = value;
                    NotifyPropertyChanged();
                }
            }
        }
        public bool OrderStockAdjusted
        {
            get => orderStockAdjusted;

            set
            {
                if (orderStockAdjusted != value)
                {

                    orderStockAdjusted = value;
                    NotifyPropertyChanged();
                }
            }
        }
        /// <summary>
        /// saga是否完毕
        /// </summary>
        /// <returns></returns>
        public override bool IsDone()
        {
            LoadData();
            return OrderCreated && OrderPaymented && OrderStockAdjusted;
        }
    }


}
